package com.citi.bond.service;

import com.citi.bond.domain.Bond;
import com.citi.bond.mapper.BondMapper;
import com.citi.bond.mapper.BondMapperExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class BondServiceImpl implements BondService {
    @Autowired
    BondMapper bondMapper;
    @Autowired
    BondMapperExt bondMapperExt;

    @Override
    public int saveBond(String name, String bond, Date date, Integer amount) {
        Bond bondObj = new Bond();
        bondObj.setSalesName(name);
        bondObj.setBondsName(bond);
        bondObj.setCreatedAt(date);
        bondObj.setAmount(amount);
        int bId = bondMapper.insert(bondObj);
        return bId;
    }
    @Override
    public List<Bond> findAllBonds(){
        return bondMapperExt.findAllBonds();
    }
}
